/*     */ package com.zimbra.cs.index.query;
/*     */ 
/*     */ import com.google.common.collect.ImmutableList;
/*     */ import com.google.common.collect.ImmutableListMultimap.Builder;
/*     */ import com.google.common.collect.Lists;
/*     */ import com.google.common.collect.Multimap;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Collection;
/*     */ import java.util.List;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public final class AttachmentQuery
/*     */   extends LuceneQuery
/*     */ {
/*  38 */   private static final ImmutableList<String> MS_WORD_TYPES = ImmutableList.of("application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "application/vnd.ms-word.document.macroenabled.12", "application/vnd.ms-word.template.macroenabled.12");
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  46 */   private static final ImmutableList<String> MS_EXCEL_TYPES = ImmutableList.of("application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "application/vnd.ms-excel.sheet.macroenabled.12", "application/vnd.ms-excel.template.macroenabled.12", "application/vnd.ms-excel.addin.macroenabled.12", "application/vnd.ms-excel.sheet.binary.macroenabled.12");
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  56 */   private static final ImmutableList<String> MS_POWERPOINT_TYPES = ImmutableList.of("application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.template", "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "application/vnd.ms-powerpoint.addin.macroenabled.12", "application/vnd.ms-powerpoint.presentation.macroenabled.12", "application/vnd.ms-powerpoint.slideshow.macroenabled.12");
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  66 */   protected static final Multimap<String, String> CONTENT_TYPES_MULTIMAP = new ImmutableListMultimap.Builder().put("any", "any").put("application", "application").put("application/*", "application").put("bmp", "image/bmp").put("image/bmp", "image/bmp").put("gif", "image/gif").put("image/gif", "image/gif").put("image", "image").put("image/*", "image").put("jpeg", "image/jpeg").put("image/jpeg", "image/jpeg").putAll("excel", MS_EXCEL_TYPES).putAll("application/vnd.ms-excel", MS_EXCEL_TYPES).putAll("xls", MS_EXCEL_TYPES).putAll("ppt", MS_POWERPOINT_TYPES).putAll("powerpoint", MS_POWERPOINT_TYPES).putAll("application/vnd.ms-powerpoint", MS_POWERPOINT_TYPES).put("ms-tnef", "application/ms-tnef").put("application/ms-tnef", "application/ms-tnef").putAll("word", MS_WORD_TYPES).putAll("application/msword", MS_WORD_TYPES).putAll("msword", MS_WORD_TYPES).put("none", "none").put("pdf", "application/pdf").put("application/pdf", "application/pdf").put("text", "text").put("text/*", "text").build();
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   private AttachmentQuery(String what)
/*     */   {
/*  98 */     super("attachment:", "attachment", what);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public static Query createQuery(String what)
/*     */   {
/* 106 */     Collection<String> types = lookup(CONTENT_TYPES_MULTIMAP, what);
/* 107 */     if (types.size() == 1) {
/* 108 */       return new AttachmentQuery((String)Lists.newArrayList(types).get(0));
/*     */     }
/* 110 */     List<Query> clauses = new ArrayList(types.size() * 2 - 1);
/* 111 */     for (String contentType : types) {
/* 112 */       if (!clauses.isEmpty()) {
/* 113 */         clauses.add(new ConjQuery(ConjQuery.Conjunction.OR));
/*     */       }
/* 115 */       clauses.add(new AttachmentQuery(contentType));
/*     */     }
/* 117 */     return new SubQuery(clauses);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public final void setModifier(Query.Modifier mod)
/*     */   {
/* 124 */     if ((mod == Query.Modifier.MINUS) && ("any".equals(this.term))) {
/* 125 */       this.term = "none";
/* 126 */       return;
/*     */     }
/* 128 */     super.setModifier(mod);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/index/query/AttachmentQuery.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */